"""
WSGI config for project.

It exposes the WSGI callable as a module-level variable named ``application``.

For more information on this file, see
https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/
"""

import os
import sys
from django.core.wsgi import get_wsgi_application

BASE_DIR = os.path.dirname(os.path.abspath(__file__))

DEV_SETTING_FILE = os.path.join(BASE_DIR, 'settings', 'dev.py')
SETTING_FILE = os.path.join(BASE_DIR, 'settings', 'production.py')

if not os.path.exists(DEV_SETTING_FILE) and not os.path.exists(SETTING_FILE):
    raise Exception('There is no production.py in settings directory.')

sys.path.append(os.path.join(os.path.dirname(BASE_DIR), 'app'))

PROJECT_NAME = os.path.basename(BASE_DIR)

os.environ.setdefault(
    "DJANGO_SETTINGS_MODULE", "%s.settings.production" % PROJECT_NAME
)

application = get_wsgi_application()
